
""""
解决钻石问题，使用super(cls,instance)
        super会先获取instance的__mro__列表，__mro__返回继承关系解析顺序列表
        找到列表中cls的下一个类，返回
        super()省略参数的时候只能调用__mro__列表中cls的下一个类
"""


class Father(object):
    def __init__(self,name):
        self.name = name
        print("I'm father")


class Son1(Father):
    def __init__(self, name, age, gender):
        self.age = age
        super(Son1, self).__init__(name, gender)
        print("I'm Son_1")


class Son2(Father):
    def __init__(self, name, gender):
        self.gender = gender
        super(Son2, self).__init__(name)
        print("I'm Son_2")


class GrandSon(Son1, Son2):  # Son_1和Son_2位置不能调换，若调换得修改super中init的参数
    def __init__(self, name, age, gender):
        super(GrandSon, self).__init__(name, age, gender)
        print("I'm gender_son")


# grand_son = GrandSon("李四",18,"男")
grand_son = GrandSon("张三", 18, "男")
print(GrandSon.__mro__)
